package com.bwie.controller;

import com.bwie.Vo.PageProdVo;
import com.bwie.pojo.TbProd;
import com.bwie.pojo.TbProdAtta;
import com.bwie.service.TbProdService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: zhaijiaqi
 * @Date: 2025/6/24 09:58
 * @Description:
 **/
@RestController
@RequestMapping("/shop/prod")
public class ProdController {

    @Autowired
    TbProdService tbProdService;


    /**
     * 分页获取商品列表
     * @return
     */
    @PostMapping("/ProdList")
    public R ProdList(@RequestBody PageProdVo pageProdVo){
    return tbProdService.ProdList(pageProdVo);
    }

    /**
     * 添加商品
     * @param tbProd
     * @return
     */
    @PostMapping("/GetAddProd")
    public R GetAddProd(@RequestBody @Validated TbProd tbProd){
        return tbProdService.GetAddProd(tbProd);
    }

    /**
     * 添加商品附件
     * @param tbProdAtta
     * @return
     */
    @PostMapping("/AddprodAtta")
    public R AddprodAtta(@RequestBody TbProdAtta tbProdAtta){

        return tbProdService.AddprodAtta(tbProdAtta);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @PostMapping("/deleteBatchProd")
    public R deleteBatchProd(@RequestBody List<Integer> ids){
        return tbProdService.deleteBatchProd(ids);
    }

    /**
     * 删除商品
     * @param prodId
     * @return
     */
    @PostMapping("/deleteProd/{prodId}")
    public R deleteProd(@PathVariable("prodId")Integer prodId){
        return tbProdService.deleteProd(prodId);
    }

    /**
     * 查询商品列表到ES
     * @return
     */
    @PostMapping("/getProdToEs")
    public R getProdToEs(@RequestBody PageProdVo pageProdVo){
        return tbProdService.getProdToEs(pageProdVo);
    }
}
